﻿using BCCommon.TMS.Insured;
using BCDto.TMS.InsuredConfig;
using BCService.TMS.InsuredConfig;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.ClientApp.InsuredConfig
{
    /// <summary>
    /// 保价配置
    /// </summary>
    [Route("api/v1/ClientApp/[controller]")]
    [ApiExplorerSettings(GroupName = "ClientApp")]
    [AllowAnonymous]
    public class InsuredConfigController : ClientAppBaseController
    {
        private readonly IInsuredConfigService insuredConfigService;

        public InsuredConfigController(IInsuredConfigService insuredConfigService)
        {
            this.insuredConfigService = insuredConfigService;
        }

        /// <summary>
        /// 获取保价配置列表
        /// </summary>
        /// <param name="insuredType">保价类型</param>
        /// <param name="vehicleTransportBusinessConfigId">车辆运输业务配置ID</param>
        /// <response code="200">获取保价配置列表</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(IEnumerable<InsuredConfigViewDto>), 200)]
        public IActionResult List([FromQuery(Name = "insured_type")] InsuredType? insuredType,
            [FromQuery(Name = "vehicle_transport_business_config_id")] int? vehicleTransportBusinessConfigId)
        {
            var result = this.insuredConfigService.GetList(null, insuredType, vehicleTransportBusinessConfigId);
            return this.Ok(result);
        }
    }
}
